<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/9
 * Time: 10:37
 */

namespace app\applet\controller;


use app\share\model\Token;
use think\Validate;

class Personal
{

    /**
     * 用户的收藏，粉丝，消息等相关接口
     */

    public function __construct(){

        $this->personal=new \app\applet\model\Personal();
        $this->token=new Token();
    }

    /**
     * 我的收藏页面
     */
    public function myCollection(){
        $member_id = get_header_id("token");
        //$member_id=5;

        $returnData=$this->personal->myCollection($member_id);

        returnJson(200,'success',$returnData);
    }

    /**
     * 商品收藏列表
     */
    public function collectionGoodsList(){
        $param=input();
        $member_id = get_header_id("token");
        $page=empty($param['current_page']) ? 1 : $param['current_page'];
        $page_size=empty($param['page_num']) ? 10: $param['page_num'];
        //$member_id=57;


        $returnData=$this->personal->goodsList($member_id,$page,$page_size);

        returnJson(200,'success',$returnData);


    }

    /**
     * 店铺收藏列表
     */
    public function collectionStoreList(){
        $param=input();
        $member_id = get_header_id("token");
        $page=empty($param['current_page']) ? 1 : $param['current_page'];
        $page_size=empty($param['page_num']) ? 10: $param['page_num'];
        //$member_id=57;


        $returnData=$this->personal->colStoreList($member_id,$page,$page_size);

        returnJson(200,'success',$returnData);


    }

    /**
     * 删除收藏
     */
    public function collectionDel(){
        $param=input();
        $validate = new Validate([
            ['c_id', 'require', '收藏id不能为空'],
        ]);
        if(!$validate->check($param))
        {
            returnJson(-2003,$validate->getError());
        }

        $c_id=$param['c_id'];
        $member_id = get_header_id("token");

        $this->personal->collectionDel($member_id,$c_id);

        returnJson(200,'操作成功');
    }

    /**
     * 收藏列表    还没有写完
     * $type 1企业展厅,2人才展厅,3征婚,4短租员工1企业展厅,2人才展厅,3征婚,4短租员工
     *      5我要兼职,6兼职招募,7投资意向,8股东招募,9加盟代理,10联合办公
     *      11企业招募,12采购邀标,13联盟商城
     */
    public function collectionList(){
        $param=input();
        $member_id = get_header_id("token");
        $page=empty($param['current_page']) ? 1 : $param['current_page'];
        $page_size=empty($param['page_num']) ? 10: $param['page_num'];
        $type=empty($param['type']) ? 13: $param['type'];

        $returnData=$this->personal->coList($member_id,$type,$page,$page_size);

        returnJson(200,'success',$returnData);


    }

    /**
     * 干货收藏列表  type 1=视频  2=音频
     */
    public function dryList(){
        $param=input();
        $member_id = get_header_id("token");
        $page=empty($param['current_page']) ? 1 : $param['current_page'];
        $page_size=empty($param['page_num']) ? 10: $param['page_num'];
        $type=empty($param['type']) ? 1: $param['type'];
        //$member_id=1;
        $returnData=$this->personal->videoList($member_id,$type,$page,$page_size);

        returnJson(200,'success',$returnData);

    }
    /**
     * 我的粉丝页面
     */
    public function myFans(){
        $member_id = get_header_id("token");
        $member_id=14;
        $store_id=$this->personal->selectStoreId($member_id);

        $returnData=$this->personal->myFans($store_id,$member_id);

        returnJson(200,'success',$returnData);
    }

    /**
     * 联盟商家粉丝列表
     */
    public function storeList(){
        $param=input();
        $member_id = get_header_id("token");
        $page=empty($param['current_page']) ? 1 : $param['current_page'];
        $page_size=empty($param['page_num']) ? 10: $param['page_num'];
        $member_id=14;

        $store_id=$this->personal->selectStoreId($member_id);

        $returnData=$this->personal->storeList($store_id,$page,$page_size);

        returnJson(200,'success',$returnData);

    }


    /**
     * 发送免费信息  ----站内信
     */
    public function sendMsg(){
        $param=input();
        $member_id = get_header_id("token");
        $validate = new Validate([
            ['content', 'require', '消息内容不能为空'],
            ['object_id', 'require', '发送对象不能为空'],
            ['class_type', 'require', '类型不能为空'],
        ]);
        if(!$validate->check($param))
        {
            returnJson(-2003,$validate->getError());
        }

        $this->personal->sendMessage($param,$member_id);

        returnJson(200,'操作成功');
    }



    public function test(){
        $returnData=$this->personal->selectStore(70);
        dump($returnData);
    }
}